import smtplib
import string
import sys
import os
 
USERNAME = 'bok.chan'
PASS = 'bluenote'
HOST = 'smtp.gmail.com:587'
SUBJECT = "BADS F2012"
BODY = 'Hej {0} and {1}\nI am Andreas one of your TA\'s and I will '
FROM = "bok.chan@gmail.com"

for top, dirs, files in os.walk('./src/') :
	for f in files :
		if f.split('.')[-1] == 'txt' : 
			info = open(os.path.join(top, f)).readlines();
			TO = info[0].strip().split('\t')[1]
			TO += ',' + info[1].strip().split('\t')[1]
			DROPBOX_LINK = info[2].strip()
			print (TO)
			print (DROPBOX_LINK)

sys.exit(0)

def sendMail(info) :
	M1 = info[0].strip().split('\t')[1]
	N1 = info[0].strip().split('\t')[0]
	
	M2 = info[1].strip().split('\t')[1]
	N2 = info[1].strip().split('\t')[0]
	
	DROPBOX_LINK = info[2].strip()
	
	text = BODY.format(N1, N2)
	BODY = "\r\n".join([
			"From: %s" % FROM,
			"To: {0},{1}".format(M1, M2),
			"Subject: %s" % SUBJECT,
			"",
			text
			])
	server = smtplib.SMTP(HOST)
	server.starttls()
	server.login(USERNAME, PASS)
	server.sendmail(FROM, [TO], BODY)
	server.quit()